package com.kly.cashmall.module.products.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kly.cashmall.R;
import com.kly.cashmall.bean.ProductDetailBean;


/**
 * author :
 * date   : 2019-12-24 15:48
 * desc   :
 */
public class ProductDetailAmountAdapter extends BaseQuickAdapter<ProductDetailBean, BaseViewHolder> {

    public ProductDetailAmountAdapter() {
        super(R.layout.item_product_details_amount);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, ProductDetailBean loanProductDetailBean) {

        TextView itemDuration = holder.getView(R.id.item_duration);
        ConstraintLayout durationSelectContent = holder.getView(R.id.duration_select_content);
        ImageView itemChecked = holder.getView(R.id.item_checked);
        itemDuration.setText(loanProductDetailBean.amount);
        if (loanProductDetailBean.locked){
            itemChecked.setVisibility(View.VISIBLE);
            itemChecked.setImageResource(R.mipmap.ic_detail_lock);
            durationSelectContent.setEnabled(false);
            durationSelectContent.setBackgroundResource(R.drawable.shape_stroke_grey_radius_4);
            itemDuration.setTextColor(getContext().getResources().getColor(R.color.color_999999));
        }else {
            itemChecked.setVisibility(View.GONE);
            durationSelectContent.setEnabled(true);
            durationSelectContent.setBackgroundResource(R.drawable.selector_product_duration);
            durationSelectContent.setSelected(loanProductDetailBean.checked);
            itemDuration.setTextColor(loanProductDetailBean.checked?getContext().getResources().getColor(R.color.color_FF5621):getContext().getResources().getColor(R.color.color_999999));

        }
    }
}
